package com.yidu.web.other;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Me {
    public static void main(String[] args) {
        You you = new You();
        Class clss = you.getClass();
        Method[] methods = clss.getDeclaredMethods();

        for(Method method:methods){
            System.out.println("取到的方法:"+method.getName());
            if(method.isAnnotationPresent(CheckTest.class) && method.getAnnotation(CheckTest.class).value().equals("yes")){
                System.out.println("注解并且运行的方法:"+method.getName());
                try {
                    method.invoke(you,null);

                } catch (Exception e) {
                    System.err.println(method.getName()+"出错了,出错的信息是:"+e.getCause().getMessage());
                }
            }
        }

    }
}
